package com.gzsxy.event;

import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent;
import org.springframework.stereotype.Component;

/**
 * @author xiaolong
 * @version 1.0
 * @description: 登陆失败监听
 * @date 2021/11/8 17:32
 */
@Component
public class AuthenticationFailureListener implements ApplicationListener<AuthenticationFailureBadCredentialsEvent> {



        @Override
        public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent authenticationFailureBadCredentialsEvent) {
            //获取当前用户名
            String username = authenticationFailureBadCredentialsEvent.getAuthentication().getPrincipal().toString();

            System.out.println("登陆失败监听 当前用户名:"+username);


            }


}
